package com.binc.testspring.controller;

import cn.hutool.json.JSONObject;
import com.binc.testspring.dto.Result;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * 这就假设这是远程的第三方接口了   方便retrofit的测试
 */
@Api(tags = "模拟三方接口")
@Slf4j
@RestController
// @RequestMapping("/third")
public class MockOtherProjectController {



    @RequestMapping("/other/binc1")
    // @ApiOperation(value = "binc2", nickname = " binc2")
    public Result<List<String>> binc1(  ) throws Exception {
        log.info("-------------------------第三方的接口,binc1 开始------------------------ ");
        return Result.of("binc1接口", "1111111111");
    }

    @RequestMapping("/binc2")
    // @ApiOperation(value = "binc2", nickname = " binc2")
    public Result<List<String>> binc2(@RequestHeader Map<String,String> headers) throws Exception {
        log.info("-------------------------第三方的接口,binc2 开始------------------------ ");
        Set<Map.Entry<String, String>> allSet = headers.entrySet();        // 将Map接口实例变为Set接口实例
        Iterator<Map.Entry<String, String>> iter = allSet.iterator();        // 实例化Iterator对象

        while (iter.hasNext()) {
            Map.Entry<String, String> me = iter.next();    //　找到Map.Entry的每对数据的实例
            System.out.println(me.getKey() + "-->" + me.getValue());    // 输出key 和 value
        }

        return Result.of("总共行。请点击 开始导入！", "12");
    }

    @ResponseBody
    @PostMapping("/third/binc3")
    public Result<Object> binc3() throws Exception {
        log.info("-------------------------第三方的接口,binc3 开始------------------------ ");

        return Result.of("第三方的接口,binc3接口", "binc3");
    }





}
